package dao

import (
	"service/app/mode"
	"service/global"

	"gorm.io/gorm"
)

type BaseDao struct {
	Orm *gorm.DB
}

func newBaseDao() BaseDao {
	return BaseDao{
		Orm: global.Db,
	}
}

// 去重
func (m *BaseDao) RmMenuduplicates(originList, acList []mode.Db_pm) []mode.Db_pm {
	for i := 0; i < len(originList); i++ {
		item := originList[i]
		for j := 0; j < len(acList); j++ {
			citem := acList[j]
			if item.ID == citem.ID {
				// 同时删除
				acList = append(acList[:j], acList[j+1:]...)
				j--
				break
			}
		}
	}
	var trimList = append(originList, acList...)
	return trimList
}
